package com.study;

import javax.swing.*;

public class LoginDemo {
    public static void main(String[] args) {
        JFrame jf = new JFrame();
        jf.setDefaultCloseOperation(3);
        jf.setAlwaysOnTop(true);
        jf.setLocationRelativeTo(null);
        jf.setTitle("用户登录");
        jf.setSize(400, 300);
        jf.setLayout(null); // 取消默认布局

        // 显示用户名文本
        JLabel usernameLabel = new JLabel("用户名");
        usernameLabel.setBounds(50,50,50,20);
        jf.add(usernameLabel);

        // 用户名输入框
        JTextField usernameField = new JTextField();
        usernameField.setBounds(150,50,180,20);
        jf.add(usernameField);

        // 显示密码文本
        JLabel passwordLabel = new JLabel("密码");
        passwordLabel.setBounds(50,100,50,20);
        jf.add(passwordLabel);

        // 密码输入框
        JPasswordField passwordField = new JPasswordField();
        passwordField.setBounds(150,100,180,20);
        jf.add(passwordField);

        // 登录按钮
        JButton loginButton = new JButton("登录");
        loginButton.setBounds(50,200,280,20);
        jf.add(loginButton);

        jf.setVisible(true);
    }
}
